#include <stdio.h>
int main()
{
    int m = 0, n = 0, i = 0, j = 0, k = 0;
    int arr1[2000] = { 0 };
    scanf_s("%d %d", &m, &n);
    k = m + n;
    for (i = 0; i < m; i++)
    {
        scanf_s("%d", &arr1[i]);
    }
    for (i = m; i < k; i++)
    {
        scanf_s("%d", &arr1[i]);
    }
    for (i = 0; i < k; i++)
    {
        for (j = i + 1; j < k; j++)
        {
            if (arr1[i] > arr1[j])
            {
                int temp = arr1[i];
                arr1[i] = arr1[j];
                arr1[j] = temp;
            }
        }
    }
    for (i = 0; i < k; i++)
    {
        printf("%d ", arr1[i]);
    }
    return 0;
}